<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MVCWeb.Models.ViewData.DocCategoryNewViewData>" %>

<%@ Register Src="~/Views/Menu/MainMenu.ascx" TagName="MainMenu" TagPrefix="mmuc" %>

<%@ Register Src="~/Views/Shared/LogOnUserControl.ascx" TagName="LogOnUserControl" TagPrefix="louc" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>Edit Document Category</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <script type="text/javascript" language="javascript">

        $(document).ready(function() {
            $("#CategoryForm").validate({
                rules:
            {
                Category:
                {
                    required: true
                },
                SortOrder:
                {
                    required: true,
                    digits: true
                }
            },

                messages:
            {
                Category:
                {
                    required: "Category name must be entered."
                },
                SortOrder:
                {
                    required: "Sort Order must be entered",
                    digits: "Sort Order must be only digits"
                }
            }
            });
            $("#submit_view").click(function() {
                $("#IsRedirectToView").val("true");
            });
        });
    </script>

    <louc:LogOnUserControl ID="LogOnUserControl1" runat="server" />
    <!-- BEGIN: MainMenu -->
    <mmuc:MainMenu ID="MainMenu1" runat="server" />
    <!-- END: MainMenu -->
    <br />
    <br />
    <h2>
        Edit Document Category</h2>
    <%--<%= Html.ValidationSummary() %>--%>
    <% using (Html.BeginForm("Edit", "DocCategory", FormMethod.Post, new { id = "CategoryForm", enctype = "multipart/form-data" }))
       {%>
    <fieldset>
        <legend>Edit Document Category</legend>
        <p>
            <label for="Category">
                Category Name:</label>
            <%= Html.TextBox("Category", ViewData.Model.DocCategory.Category.Replace("-- ","")) %>
            <%--<%= Html.ValidationMessage("Category", "*") %>--%>
        </p>
        <p>
            <label for="IsRoot" class="inline">
                Is root category:</label>
            <%= Html.CheckBox("IsRoot", ViewData.Model.DocCategory.ParentDocCategoryId == 0 ? true : false)%>
        </p>
        <p>
            <label for="ParentDocCategoryId">
                Or is child of parent category:</label>
            <%= Html.DropDownList("ParentDocCategoryId", new SelectList(ViewData.Model.Categories, "DocCategoryID", "Category", ViewData.Model.DocCategory.ParentDocCategoryId ))%>
        </p>
        <p>
            <label for="Desc">
                Description:</label>
            <%= Html.TextBox("Desc", ViewData.Model.DocCategory.Desc)%>
        </p>
        <p>
            <label for="IsCommunityDoc" class="inline">
                Is community document:</label>
            <%= Html.CheckBox("IsCommunityDoc", ViewData.Model.DocCategory.IsCommunityDoc)%>
        </p>
        <p>
            <label for="SortOrder">
                Sort Order:</label>
            <%= Html.TextBox("SortOrder", ViewData.Model.DocCategory.SortOrder)%>
        </p>
        <p>
            <%= Html.Hidden("IsRedirectToView")%>
            <input id="submit" name="submit" type="submit" value="Update" />
            <input id="submit_view" name="submit_view" type="submit" value="Update & View" />            
            <input type="reset" value="Reset" />
        </p>
    </fieldset>
    <% } %>
    <div>
        <%=Html.ActionLink("Back to List", "Index") %>
    </div>
</asp:Content>
